<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace Admin\Model;

use Think\Model;
/**
 * Description of OrderModel
 *
 * @author Administrator
 */
class OrderModel extends Model {
    //put your code here
    
    protected  $tableName = 'order';
    
    public function getList($where=[],$limit=10,$needPage=true){
		if($needPage){
			$count = $this->where($where)->count();
			$p = getPage($count,$limit);
			$data = $this->where($where)->limit($p->firstRow, $p->listRows)->order('ctime desc')->select();
			return array('data'=>$data,'page'=>$p->show());
			
		}else{
			$data = $this->where($where)->order('ctime desc')->select();
			return array('data'=>$data);
		}
        
    }
    
    public function getInfo($order_id){
        return $this->where("id=".$order_id)->find();
    }
	
	public function changeStatus($order_id,$data){
		return $this->where("id=".$order_id)->save($data);
	}
}
